The present invention relates to communication networks and more particularly to systems and methods for managing packets in a network device that processes packets such as a router.
In a typical router, packets to be forwarded via the router are temporarily stored in a high speed packet memory. The router includes a processing device that performs various operations on the packets stored in memory. The router software executing on the processing device is preferably divided into various routines or processes, referred to herein as clients. Many of these clients access the packet memory to read from packets, write to packets, allocate or deallocate memory space for packets, etc.
Problems, however, arise in permitting clients direct access to packet memory. Erroneous processing by any one client may result in that client using an incorrect pointer value to access packet memory. For example, a client may inadvertently overwrite the contents of a packet to which it is not permitted access, thereby affecting the operation of other clients and corrupting data relayed by the router. With numerous clients operating independently, the chances of one client corrupting packet data in this way are very high.
Systems and methods for managing packet memory are provided by virtue of the present invention. Various clients in a router need to read from and/or write to the contents of individual packets. In one embodiment, all accesses to packet memory are via a packet manager. Individual clients are issued packet handles to use in identifying particular packets to the packet manager. The packet manager translates between the packet handles and pointers to packet memory locations. To assure robust performance after restarting the packet manager, each packet handle indicates which run version of the packet manager was responsible for generating the handle. The packet manager rejects requests for packet access including handles generated by previous versions.
A first aspect of the present invention provides a method for providing packet processing routines with access to packets stored in a memory. The method includes using a packet manager routine to receive a request for access to a selected packet. The request includes a packet handle. The packet handle includes an identifier specifying a run version of the packet routine and an identifier specifying the selected packet. The method further includes: checking the run version specified in the packet handle against a current run version of the packet manager routine, and fulfilling the request only if the current run version matches the run version specified in the packet handle.
A second aspect of the present invention provides a method for providing packet processing routines with access to packets stored in a memory. The method includes transferring a packet handle from a packet processing routine to a packet management routine. The packet handle includes an identifier identifying a selected one of the packets. The method further includes: using the packet management routine to translate the identifier into a pointer to the memory, and accessing the memory at a location identified by the pointer.
A further understanding of the nature and advantages of the inventions herein may be realized by reference to the remaining portions of the specification and the attached drawings.